package nodes;

import compiler.Compiler;
import compiler.SymbolTable;

import descriptors.AbstractDescr;
import descriptors.ConstDescr;

public class NegationNode extends ExpressionNode {

	private AbstractNode term;
	
	public NegationNode(AbstractNode term,int line, int column){
		super(line,column);
		this.term=term;
	}
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public AbstractDescr compile(
			SymbolTable symbolTable, Compiler compiler) {
			compiler.write("PUSHI, 0");
			AbstractDescr descr = term.compile(symbolTable,compiler);
			if (descr instanceof ConstDescr) {
				compiler.write("PUSHI, " + ((ConstDescr) descr).value());
			}
			compiler.write("SUB");
		return null;
	}

	@Override
	public void print() {
		trace("NegationNode");
		term.print();
		unindent();
	}

}
